//
// Created by hsj on 2022/3/9.
//

#include "t_set.h"
namespace t_set_test{
    //打印int数值
    void out_int(int &n){
        cout<<n<<endl;
    }

    //test
    void test(){
           string s1[N]{"buffoon","thinkers","for","heavy","can","for"};
           string s2[N]{"metal","any","food","elegant","deliver","for"};

           set<string> A(s1,s1 + N);
           set<string> B(s2,s2 + N);

           ostream_iterator<string,char> out(cout," ");
           cout<<"Set A:";
           copy(A.begin(),A.end(),out);
           cout<<endl;
           cout<<"Set B:";
           copy(B.begin(),B.end(),out);
           cout<<endl;

           cout<<"unin A B:";
           set_union(A.begin(),A.end(),B.begin(),B.end(),out);
           cout<<endl;

           //合并之后复制到C集合
           set<string> C;
           cout<<"C:"<<endl;
           set_union(A.begin(),A.end(),B.begin(),B.end(),insert_iterator<set<string>>(C,C.begin()));
           copy(C.begin(),C.end(),out);
           cout<<endl;

           //插入到开始
           C.insert(string("HSJ"));
           copy(C.begin(),C.end(),out);
           cout<<endl;
    }
}